package com.fitso.model.bean.nutrition;

import java.util.ArrayList;
import java.util.List;

import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;

import com.fitso.model.bean.measure.energy.Calorie;
import com.fitso.model.bean.measure.mass.Gram;
import com.fitso.model.bean.measure.mass.Mass;

/**
 * <p>
 * Trace {@link Nutrient} compound required by organims.
 * </p>
 * 
 * @author timothy storm
 * @see <a href="http://en.wikipedia.org/wiki/Vitamin">Vitamin</a>
 * @see <a href="http://en.wikipedia.org/wiki/Mineral">Mineral</a>
 */
public class Vitamins extends Nutrient {
	// Only change on breaking changes, i.e., removing fields
	private static final long serialVersionUID = 1L;
	
	private Mass _a, _b, _b12, _b6, _biotin, _c, _d, _e, _folate, _k, _niacin, _pantothenicAcid, _riboflavin,
			_thiamine;

	public Vitamins() {}

	public Mass getA() {
		return _a;
	}

	public Mass getB() {
		return _b;
	}

	public Mass getB12() {
		return _b12;
	}

	public Mass getB6() {
		return _b6;
	}

	public Mass getBiotin() {
		return _biotin;
	}

	public Mass getC() {
		return _c;
	}

	public Mass getD() {
		return _d;
	}

	public Mass getE() {
		return _e;
	}

	public Mass getFolate() {
		return _folate;
	}

	public Mass getK() {
		return _k;
	}

	public Mass getNiacin() {
		return _niacin;
	}

	public Mass getPantothenicAcid() {
		return _pantothenicAcid;
	}

	public Mass getRiboflavin() {
		return _riboflavin;
	}

	public Mass getThiamine() {
		return _thiamine;
	}

	public void setA(Mass a) {
		_a = a;
	}

	public void setB(Mass b) {
		_b = b;
	}

	public void setB12(Mass b12) {
		_b12 = b12;
	}

	public void setB6(Mass b6) {
		_b6 = b6;
	}

	public void setBiotin(Mass biotin) {
		_biotin = biotin;
	}

	public void setC(Mass c) {
		_c = c;
	}

	public void setD(Mass d) {
		_d = d;
	}

	public void setE(Mass e) {
		_e = e;
	}

	public void setFolate(Mass folate) {
		_folate = folate;
	}

	public void setK(Mass k) {
		_k = k;
	}

	public void setNiacin(Mass niacin) {
		_niacin = niacin;
	}

	public void setPantothenicAcid(Mass pantothenicAcid) {
		_pantothenicAcid = pantothenicAcid;
	}

	public void setRiboflavin(Mass riboflavin) {
		_riboflavin = riboflavin;
	}

	public void setThiamine(Mass thiamine) {
		_thiamine = thiamine;
	}

	public boolean equals(Object o) {
		if (o == null) {
			return false;
		}
		if (o == this) {
			return true;
		}
		if (o.getClass() != getClass()) {
			return false;
		}

		Vitamins other = (Vitamins) o;
		return new EqualsBuilder().append(_a, other._a).append(_b, other._b).append(_b12, other._b12).append(_b6,
				other._b6).append(_biotin, other._biotin).append(_c, other._c).append(_d, other._d)
				.append(_e, other._e).append(_folate, other._folate).append(_k, other._k)
				.append(_niacin, other._niacin).append(_pantothenicAcid, other._pantothenicAcid).append(_riboflavin,
						other._riboflavin).append(_thiamine, other._thiamine).isEquals();
	}

	public int hashCode() {
		return new HashCodeBuilder().append(_a).append(_b).append(_b12).append(_b6).append(_biotin).append(_c).append(
				_d).append(_e).append(_folate).append(_k).append(_niacin).append(_pantothenicAcid).append(_riboflavin)
				.append(_thiamine).toHashCode();
	}

	public Mass[] getAllVitamins() {
		List<Mass> vitamins = new ArrayList<Mass>();
		vitamins.add(_a);
		vitamins.add(_b);
		vitamins.add(_b12);
		vitamins.add(_b6);
		vitamins.add(_biotin);
		vitamins.add(_c);
		vitamins.add(_d);
		vitamins.add(_e);
		vitamins.add(_folate);
		vitamins.add(_k);
		vitamins.add(_niacin);
		vitamins.add(_pantothenicAcid);
		vitamins.add(_riboflavin);
		vitamins.add(_thiamine);
		return vitamins.toArray(new Mass[vitamins.size()]);
	}

	@Override
	public Mass getMass() {
		Mass totalMass = new Gram(0);

		for (Mass m : getAllVitamins()) {
			totalMass.add(m);
		}
		return totalMass;
	}

	protected Calorie getCaloriesPerGram() {
		return new Calorie(0);
	}
}
